package uscdb.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.search.annotations.Analyzer;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;

@Entity
@Table(name = "tversion")
@DynamicInsert(true)
@DynamicUpdate(true)
@Indexed
@Analyzer(impl = org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer.class)
public class Tversion implements java.io.Serializable {

	private static final long serialVersionUID = 7706821810467617696L;
	private String id;
	/**
	 * 版本名称
	 */
	private String name;
	/**
	 * 版本描述
	 */
	private String description;
	/**
	 * 一个版本会有很多的logic file
	 */
	private Set<Tlogicfile> tlogicfileSet = new HashSet<Tlogicfile>();

	/**
	 * 一个版本只归属于一个产品
	 */
	private Tproduct tproduct;

	@Id
	@Column(name = "ID", unique = true, nullable = false, length = 36)
	@DocumentId
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "name")
	@Field(store = Store.YES) // 表示存储索引
//	@FieldBridge(impl = ClobFieldBridge.class)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "tversion")
	public Set<Tlogicfile> getTlogicfileSet() {
		return tlogicfileSet;
	}

	public void setTlogicfileSet(Set<Tlogicfile> tlogicfileSet) {
		this.tlogicfileSet = tlogicfileSet;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "TPRODUCT_ID")
	public Tproduct getTproduct() {
		return tproduct;
	}

	public void setTproduct(Tproduct tproduct) {
		this.tproduct = tproduct;
	}

	@Column(name = "description", length = 1000)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Tversion() {
		super();
		// TODO Auto-generated constructor stub
	}

}
